package com.yootk;
import java.util.concurrent.*;
public class YootkDemo07 {
    public static void main(String[] args) throws  Exception {
        Semaphore semaphore = new Semaphore(2);
        for (int x = 0; x < 5; x++) {
            new Thread(() -> {
                try{
                    semaphore.acquire();
                    if(semaphore.availablePermits() >= 0){
                        System.out.println("【业务办理-开始】当前的业务办理人员为：" + Thread.currentThread().getName());
                        TimeUnit.SECONDS.sleep(2);
                        System.out.println("【业务办理-结束】当前的业务办理人员为：" + Thread.currentThread().getName());
                        semaphore.release();
                    }
                }catch (Exception e){}
            }, "用户-" + x).start();
        }
    }
}
